﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Exhibition.Common.Helper;
using Exhibition.Dao.ViewModel;
using Exhibition.Service;

namespace Exhibition.Manage
{
    public partial class PavilionDetail : BaseAdminPage
    {
        PavilionModel model = new PavilionModel();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                hfId.Value = reqID.ToString();
                GetPavilion();
            }

        }

        private void GetPavilion()
        {

            model = CenterService.pavilionService.GetOneById(reqID);
            if (model != null)
            {

                //展馆名称
                txtPaName.Value = model.PaName.ToString();

                //展馆长
                txtPaLength.Value = model.PaLength.ToString();

                //展馆宽
                txtPaWidth.Value = model.PaWidth.ToString();

                //排序
                txtOrderID.Value = model.OrderID.ToString();


            }

        }

        /// <summary>
        /// 保存一条数据
        /// <summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {

            model = string.IsNullOrEmpty(hfId.Value)||hfId.Value=="0" ? new PavilionModel() : CenterService.pavilionService.GetOneById(Convert.ToInt32(hfId.Value));
            //展馆名称
            model.PaName = txtPaName.Value;

            //展馆长
            model.PaLength = Convert.ToInt32(txtPaLength.Value);

            //展馆宽
            model.PaWidth = Convert.ToInt32(txtPaWidth.Value);

            //排序
            model.OrderID = Convert.ToInt32(txtOrderID.Value);

            model.CreateUserId = AdminUser.Id;
            model.SiteID = CurrentSite.Id;

            if (CenterService.pavilionService.Save(model) > 0)
            {

                JsHelper.Unblock(this, CommFunMsg.GetMessage("A0001", Lan.zh));
            }
            else
            {
                JsHelper.Unblock(this, CommFunMsg.GetMessage("e0001", Lan.zh));
            }
        }
    }
}

      

   